<template>
  <!-- 短信使用明细 -->
<div>
  <el-form class="search-form-new" :model="queryParams" ref="queryForm" :inline="true">
      <div class="search-box">
       
        <el-form-item label="时间" prop="">
          <el-date-picker style="width: 300px" v-model="timer" type="daterange" align="right" unlink-panels range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"  >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="类型" prop="status">
          <el-select clearable v-model="queryParams.status" placeholder="请选择类型"  >
            <el-option  label="充值" :value="1" />
            <el-option  label="扣除" :value="2" />
          </el-select>
        </el-form-item>

        <el-form-item class="btns">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置/刷新</el-button>
        </el-form-item>
      </div>
    </el-form>
  <div class="table_box">
    <el-table
        :data="tableData.records"
        style="width: 100%"
        stripe
      
      >
      <el-table-column
          prop="tenantName"
          label="商户"
          show-overflow-tooltip
        ></el-table-column>
      <el-table-column
          prop="createName"
          label="用户"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column prop="phone" label="手机号" width="110"></el-table-column>
        <el-table-column prop="msg" label="说明" ></el-table-column>
        <el-table-column
          prop="orderStatus"
          label="变动类型"
          width="80"
        >
        <template slot-scope="scope">
            <span style="color: yellowgreen;" v-show="scope.row.status==1">充值</span>
            <span style="color: red;" v-show="scope.row.status==2">扣除</span>
        </template>
        </el-table-column>
        <el-table-column prop="changeNumber" label="变动数量" width="100"></el-table-column>
        <el-table-column prop="lastSystemNum" label="免费短信余量" width="110"></el-table-column>
        <el-table-column prop="lastPackageNum" label="短信包余量" width="100"></el-table-column>
        <el-table-column
          prop="createTime"
          label="时间"
          width="160"
        ></el-table-column>
      </el-table>
      <div style="text-align: right;">
    <pagination v-show="tableData.total > 0" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
</div>
  </div>
</div>
  
</template>
<script>
import { mapGetters } from "vuex";
import myMoneyApi from "@/api/financeCenter/myMoney.js";
export default {
  name: "",
  computed: {
    ...mapGetters(["userInfo"]),
  },
  data() {
    return {
      dialogVisible:false,
      timer:[],
      tableData:{
        records:[],
        total:0,
      },
      
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
    };
  },
  created() {
      this.getList()
  },
  methods: {
   
    // 获取列表
    getList() {
      // queryParams 请求列表
      this.loading = true;
      if (this.timer && this.timer.length == 2) {
        this.queryParams.createTimeStart = this.timer[0] + " 00:00:00";
        this.queryParams.createTimeEnd = this.timer[1] + " 23:59:59";
      } else {
        this.queryParams.createTimeStart = "";
        this.queryParams.createTimeEnd = "";
      }
      myMoneyApi.tenantSmsRecordList(this.queryParams).then((res) => {
        this.loading = false;
        this.tableData.records = res.rows;
        this.tableData.total = res.total;
      });
    },

   
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.timer = []
      this.handleQuery();
    },
    resetQuery() {
      this.timer = [];
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        createTimeStart: "",
        createTimeEnd: ""
      };
      this.getList();
    },

  }
};
</script>
<style lang="scss" scoped>
  .app-container{
    padding: 0px;
    .search-box{
      // width: 790px;
      // margin: 0 auto;
    }
  }
</style>
